<?php

/**
 * Usuario form base class.
 *
 * @method Usuario getObject() Returns the current form's model object
 *
 * @package    auip
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseUsuario2Form extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'email'     => new sfWidgetFormInputText(array('label' => 'Email')),
      'nombre'    => new sfWidgetFormInputText(array('label' => 'Nombre')),
      'apellidos' => new sfWidgetFormInputText(array('label' => 'Apellidos')),
      'password'  => new sfWidgetFormInputPassword(array('label' => 'Contraseña')),
      'password2'  => new sfWidgetFormInputPassword(array('label' => 'Confirmar Contraseña'), array('maxlength'=>'10')),
    ));

    $this->setValidators(array(
      'email'     => new sfValidatorEmail(array('required'=>true), array('required'=> "El email es obligatorio")),
      'nombre'    => new sfValidatorString(),
      'apellidos' => new sfValidatorString(),
      'password'  => new sfValidatorString(),
      'password2'  => new sfValidatorString(),
    ));

    $this->widgetSchema->setNameFormat('usuario[%s]');
/*
    $this->validatorSchema->setPostValidator(new sfValidatorAnd(array(
            new sfValidatorSchemaCompare('password2', sfValidatorSchemaCompare::EQUAL, 'password', array('throw_global_error' => true), array('invalid' => "Las dos contraseñas no coinciden")),
            new sfValidatorDoctrineUnique(array('model' => 'Usuario', 'column' => 'email', 'primary_key' => 'id', 'required' => true), array('invalid'=> "Este email ya está en uso"))
        )));

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
*/
    $decorator = new myWidgetFormSchemaFormatterCustom($this->getWidgetSchema());
  	$this->widgetSchema->addFormFormatter('custom', $decorator);
  	$this->widgetSchema->setFormFormatterName('custom');
    
    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Usuario';
  }

}//
